package main.java.org.mapper;

import main.java.Exam.pojo.Entity.User;
import org.apache.ibatis.annotations.*;


@Mapper
public interface UserMapper {
    //检查账号是否存在
    @Select("SELECT id, userAccount,userName, password, gender, phone, role_id, class_id, status, is_deleted " +
            "FROM tb_user " +
            "WHERE userAccount = #{userAccount} " +
            "AND is_deleted = 0")
    public User selectByUsername(@Param("userAccount") String userAccount);
  //检查号码是否存在。如果存在说明注册过了
  @Select("select * from tb_user where phone = #{phone} and is_deleted = 0")
  User selectByPhone(String phone); // 检查手机号是否存在
//添加账号
    @Insert("insert into tb_user ( userName,userAccount, password, phone, role_id) " +
            "values (#{userName},#{userAccount}, #{password}, #{phone}, #{roleId})")
    void insert(User user); // 新增用户

    @Update("UPDATE tb_user SET password = #{password} WHERE userName = #{userName}")
    void update( String password,String userName);

@Select("select userName,userAccount,phone,role_id from tb_user where id=#{id}")
    User getuser(Long id);
    @Update("UPDATE tb_user SET userName = #{userName}, phone = #{phone} WHERE id = #{id}")
    void update1(User user);

    @Select("select userName from tb_user where userAccount=#{userAccount}")
    String getuserName(String userAccount);
}
